/**
 * Copyright (c) Software Institude of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.model.uml.Collaborations;
// imports:
import org.w3c.dom.Element;

import edu.pku.sei.gefcommon.descriptor.annotation.MethodProperty;
import edu.pku.sei.modeler.model.common.*;
import edu.pku.sei.modeler.model.core.*;
import edu.pku.sei.modeler.model.xml.XMLUtility;

import edu.pku.sei.modeler.model.uml.InternalStructures.ConnectableElement;
import edu.pku.sei.modeler.model.uml.BasicBehaviors.Behavior;
import edu.pku.sei.modeler.model.uml.Communications.Trigger;
import edu.pku.sei.modeler.model.uml.Interfaces.InterfaceRealization;
import edu.pku.sei.modeler.model.uml.BasicBehaviors.Behavior;
import edu.pku.sei.modeler.model.uml.Kernel.Property;
import edu.pku.sei.modeler.model.uml.Kernel.Classifier;
import edu.pku.sei.modeler.model.uml.Kernel.Operation;
import edu.pku.sei.modeler.model.uml.Kernel.UMLClass;
import edu.pku.sei.modeler.model.uml.Communications.Reception;

import edu.pku.sei.modeler.model.uml.InternalStructures.StructuredClassifier;
import edu.pku.sei.modeler.uml.modelHelper.ModelPackage;

/**
 * @generated
 *
 */
public class Collaboration extends StructuredClassifier implements ICollaboration {
	// attributes
	
	
	
	protected boolean isActive;
	
	
	// references
	
	protected MetaTypedList collaborationRole;
	
	
	
	protected MetaTypedList ownedBehavior;
	
	protected MetaTypedList ownedTrigger;
	
	protected MetaTypedList interfaceRealization;
	
	protected MetaTypedList classifierBehavior;
	
	protected MetaTypedList ownedAttribute;
	
	protected MetaTypedList nestedClassifier;
	
	protected MetaTypedList ownedOperation;
	
	protected MetaTypedList superClass;
	
	protected MetaTypedList ownedReception;
	
	// getters & setters for attributes
	
	@MethodProperty(
			id = "COLLABORATION_ISACTIVE",
			catalog = "Model",
			name = ModelPackage.UMLCLASS_ISACTIVE,
			setter = "setisActive"
			)
	
	public boolean getIsActive() {
		return isActive;
	}
	public void setIsActive(boolean newIsActive) {
		boolean oldisActive = isActive;
		isActive = newIsActive;
		firePropertyChange(ModelPackage.UMLCLASS_ISACTIVE, oldisActive, newIsActive);
	}
	
	// getters for references
	
	public MetaTypedList getCollaborationRole() {
		if(collaborationRole == null) {
			collaborationRole = new MetaTypedList(ConnectableElement.class, this, ModelPackage.COLLABORATION_COLLABORATIONROLE);
		}
		return collaborationRole;
	}
	
	public MetaTypedList getOwnedBehavior() {
		if(ownedBehavior == null) {
			ownedBehavior = new MetaTypedList(Behavior.class, this, ModelPackage.BEHAVIOREDCLASSIFIER_OWNEDBEHAVIOR);
		}
		return ownedBehavior;
	}
	
	public MetaTypedList getOwnedTrigger() {
		if(ownedTrigger == null) {
			ownedTrigger = new MetaTypedList(Trigger.class, this, ModelPackage.BEHAVIOREDCLASSIFIER_OWNEDTRIGGER);
		}
		return ownedTrigger;
	}
	
	public MetaTypedList getInterfaceRealization() {
		if(interfaceRealization == null) {
			interfaceRealization = new MetaTypedList(InterfaceRealization.class, this, ModelPackage.BEHAVIOREDCLASSIFIER_INTERFACEREALIZATION);
		}
		return interfaceRealization;
	}
	
	public MetaTypedList getClassifierBehavior() {
		if(classifierBehavior == null) {
			classifierBehavior = new MetaTypedList(Behavior.class, this, ModelPackage.BEHAVIOREDCLASSIFIER_CLASSIFIERBEHAVIOR);
		}
		return classifierBehavior;
	}
	
	public MetaTypedList getOwnedAttribute() {
		if(ownedAttribute == null) {
			ownedAttribute = new MetaTypedList(Property.class, this, ModelPackage.UMLCLASS_OWNEDATTRIBUTE);
		}
		return ownedAttribute;
	}
	
	public MetaTypedList getNestedClassifier() {
		if(nestedClassifier == null) {
			nestedClassifier = new MetaTypedList(Classifier.class, this, ModelPackage.UMLCLASS_NESTEDCLASSIFIER);
		}
		return nestedClassifier;
	}
	
	public MetaTypedList getOwnedOperation() {
		if(ownedOperation == null) {
			ownedOperation = new MetaTypedList(Operation.class, this, ModelPackage.UMLCLASS_OWNEDOPERATION);
		}
		return ownedOperation;
	}
	
	public MetaTypedList getSuperClass() {
		if(superClass == null) {
			superClass = new MetaTypedList(UMLClass.class, this, ModelPackage.UMLCLASS_SUPERCLASS);
		}
		return superClass;
	}
	
	public MetaTypedList getOwnedReception() {
		if(ownedReception == null) {
			ownedReception = new MetaTypedList(Reception.class, this, ModelPackage.UMLCLASS_OWNEDRECEPTION);
		}
		return ownedReception;
	}
	
	// save & load
	public void serialize(Element root) {
		super.serialize(root);
		// attributes
		
		XMLUtility.xmlInstance.serializeAttribute(root, ModelPackage.UMLCLASS_ISACTIVE, isActive);
		
		// references
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.COLLABORATION_COLLABORATIONROLE, collaborationRole);		
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.BEHAVIOREDCLASSIFIER_OWNEDBEHAVIOR, ownedBehavior);
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.BEHAVIOREDCLASSIFIER_OWNEDTRIGGER, ownedTrigger);
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.BEHAVIOREDCLASSIFIER_INTERFACEREALIZATION, interfaceRealization);
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.BEHAVIOREDCLASSIFIER_CLASSIFIERBEHAVIOR, classifierBehavior);		
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.UMLCLASS_OWNEDATTRIBUTE, ownedAttribute);
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.UMLCLASS_NESTEDCLASSIFIER, nestedClassifier);
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.UMLCLASS_OWNEDOPERATION, ownedOperation);
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.UMLCLASS_SUPERCLASS, superClass);		
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.UMLCLASS_OWNEDRECEPTION, ownedReception);
		
	}
	
	public void deSerialize(Element root) {
		super.deSerialize(root);
		// attributes
		
		isActive = XMLUtility.xmlInstance.deSerializeBoolean(root, ModelPackage.UMLCLASS_ISACTIVE);
		
		// references
		
		this.getCollaborationRole().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.COLLABORATION_COLLABORATIONROLE, this));
		
		this.getOwnedBehavior().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.BEHAVIOREDCLASSIFIER_OWNEDBEHAVIOR));
		
		this.getOwnedTrigger().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.BEHAVIOREDCLASSIFIER_OWNEDTRIGGER));
		
		this.getInterfaceRealization().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.BEHAVIOREDCLASSIFIER_INTERFACEREALIZATION));
		
		this.getClassifierBehavior().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.BEHAVIOREDCLASSIFIER_CLASSIFIERBEHAVIOR, this));
		
		this.getOwnedAttribute().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.UMLCLASS_OWNEDATTRIBUTE));
		
		this.getNestedClassifier().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.UMLCLASS_NESTEDCLASSIFIER));
		
		this.getOwnedOperation().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.UMLCLASS_OWNEDOPERATION));
		
		this.getSuperClass().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.UMLCLASS_SUPERCLASS, this));
		
		this.getOwnedReception().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.UMLCLASS_OWNEDRECEPTION));
		
	}
	
	public void dynamicSet(String featureID, Object value) {
		if(featureID == null || "".equals(featureID)) {
			return;
		}
		// attributes
		
		// references
		
		else if(ModelPackage.COLLABORATION_COLLABORATIONROLE.equals(featureID)) {
			getCollaborationRole().add(value);
		}
		
		else if(ModelPackage.BEHAVIOREDCLASSIFIER_CLASSIFIERBEHAVIOR.equals(featureID)) {
			getClassifierBehavior().add(value);
		}
		
		else if(ModelPackage.UMLCLASS_SUPERCLASS.equals(featureID)) {
			getSuperClass().add(value);
		}
		
		else
			super.dynamicSet(featureID, value);
	}
}
 
 
 
 
 